<#include "/WEB-INF/template/common/macro/base.ftl"/>
<#include "/WEB-INF/template/common/layout/l_admin.ftl"/>
<#--上传组件导入-->
<#include "/WEB-INF/template/common/macro/fileupload.ftl"/>
<#include "/WEB-INF/template/common/macro/umeditor.ftl"/>
<@adminLayout>
    <@breadcrumb view=breadcrumbView/>
<form action="${CONTEXT_PATH}/banners/save" method="post" id="banner_add">
    <#include "/WEB-INF/template/page/admin/banner/_form.ftl"/>
    <@script>
        <@libs_fileupload/>
        <@lib_umeditor/>
        <script type="text/javascript">
            jQuery(document).ready(function () {
                /*设置umeditor目录路径*/
                window.UMEDITOR_CONFIG.UMEDITOR_HOME_URL = "${CONTEXT_PATH}/plugin/umeditor/";
                /*设置图片上传路径*/
                window.UMEDITOR_CONFIG.imageUrl = "${CONTEXT_PATH}/umectr/ueupload";
                window.UMEDITOR_CONFIG = $.extend(window.UMEDITOR_CONFIG, {imagePath: "${CONTEXT_PATH}/umectr/loadimg/"});
                window.um = UM.getEditor('umeditor', {
                    /* 传入配置参数,可配参数列表看umeditor.config.js */
                    toolbar: ['source | undo redo | bold italic underline strikethrough | forecolor backcolor | removeformat |',
                        'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
                        '| justifyleft justifycenter justifyright justifyjustify |',
                        'link unlink | emotion image video ',
                        '| horizontal print preview fullscreen', 'drafts', 'formula']
                });
                window.um.addListener('blur', function () {
                    $("[name='m.text']").val(window.um.getContent());
                });
                $("#imgurl").fileupload({
                    url: "${CONTEXT_PATH}/updown/up",//文件上传地址，当然也可以直接写在input的data-url属性内
                    //formData:{param1:"p1",param2:"p2"},//如果需要额外添加参数可以在这里添加
                    done: function (e, data) {
                        $("#callbackimg").attr("src", "${CONTEXT_PATH}" + data.result.url);
                        $("[name='m.imgurl']").val(data.result.url);
                    }
                });
            });
            function ajaxsub() {
                $("#banner_add").ajaxSubmit(function (data, status, xhr) {
                    if (data.status) {
                        toastr.success(data.msg, '操作提示');
                    } else {
                        toastr.error(data.msg, '操作提示');
                    }
                });
            }
        </script>
    </@script>

</form>

</@adminLayout>
